package com.itheima.duotai.test5;

public class Demo5 {
    public static void main(String[] args) {
        Laptop laptop = new Laptop();
        laptop.switchOn();
        laptop.getUSB(new Mouse());
        laptop.getUSB(new KeyBoard());
        laptop.switchOff();
    }
}

interface USB{
    void connect();
    void disconnect();
}

class Laptop{
    public void switchOn(){
        System.out.println("笔记本开机");
    }
    public void switchOff(){
        System.out.println("笔记本关机");
    }

    public void getUSB(USB u){
        u.connect();
        u.disconnect();
    }
}
class Mouse implements USB{

    @Override
    public void connect() {
        System.out.println("连接鼠标的USB");
    }

    @Override
    public void disconnect() {
        System.out.println("断开鼠标的USB");
    }
}
class KeyBoard implements USB{

    @Override
    public void connect() {
        System.out.println("连接键盘的USB");
    }

    @Override
    public void disconnect() {
        System.out.println("断开键盘的USB");
    }
}